package com.mes.bac.backend.controller;

import com.mes.bac.backend.common.vo.R;
import com.mes.bac.backend.service.IForecastService;
import com.mes.bac.backend.vo.ForecastResultVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Tag(name = "7. 生产预测", description = "提供产能预测功能")
@RestController
@RequestMapping("/api/forecast")
public class ForecastController {

    @Autowired
    private IForecastService forecastService;

    @Operation(summary = "获取生产预测数据")
    @GetMapping("/predict")
    public R<ForecastResultVO> predict(@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate targetDate) {
        return R.success(forecastService.predict(targetDate));
    }
}